#include "History.h"
//@author A0105475H


History::History(void)
{
}


History::~History(void)
{
}

bool History::isUndoEmpty()
{
	return (undo.size() == CommonConstant::HISTORY_EMPTY_SIZE);
}

bool History::isRedoEmpty()
{
	return (redo.size() == CommonConstant::HISTORY_EMPTY_SIZE);
}

ICommand* History::getRedo()
{
	if (isRedoEmpty())
	{
		throw CommonConstant::MESSAGE_NO_REDOABLE_TASK;
	}
	else
	{
		ICommand* cmd=redo.top();
		assert(cmd != NULL);
		undo.push(cmd);
		redo.pop();
		return cmd;
	}
}

ICommand* History::getUndo()
{
	if (isUndoEmpty())
	{
		throw CommonConstant::MESSAGE_NO_UNDOABLE_TASK;
	}
	else
	{
		ICommand* cmd=undo.top();
		assert(cmd != NULL);
		redo.push(cmd);
		undo.pop();
		return cmd;
	}	
}

void History::InsertUndoRedo(ICommand* cmd)
{
	undo.push(cmd);
	redo.empty();
}
